/*************************************************************************
	> File Name: command.h
	> Author: ma6174
	> Mail: ma6174@163.com 
	> Created Time: 2021年12月08日 星期三 22时09分44秒
 ************************************************************************/

#include<iostream>
#include <string>

struct Receiver
{
	void action()
	{
		std::cout << "执行请求!" << std::endl;
	}
};

class Command
{
public:
	Command() = default;
	Command(Receiver re) : receiver(re) {}

	virtual void execute() = 0;

protected:
	Receiver receiver;
};

class ConcreteCommand : public Command
{
public:
	using Command::Command;
	virtual void execute()
	{
		receiver.action();
	}
};


class Invoker
{
public:
	void setCommand(Command* cmd)
	{
		this->command = cmd;
	}

	void executeCommand()
	{
		command->execute();
	}

private:
	Command* command;
};
